﻿using System;
using System.Web;
using MySql.Data.MySqlClient;
using System.Data;

namespace KeDa2025_
{
    /// <summary>
    /// CheckAccountHandler 的摘要说明
    /// </summary>
    public class CheckAccountHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            //接收tom
            string account = context.Request["Account"];
            //去数据库查有没有tom
            string sql = string.Format("select * from user where name='{0}'", account);
            MySqlConnection connection = new MySqlConnection("server=localhost;user id=zmy2;password=zmy20020525;database=forum;");
            MySqlDataAdapter sqlDataAdapter = new MySqlDataAdapter(sql, connection);
            DataSet ds = new DataSet();
            sqlDataAdapter.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                context.Response.Write("false");//账号存在  不可用

            }
            else
            {
                context.Response.Write("true");//账号不存在  可用
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}